﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SubstrateHelper.Models
{
    public class QueryTerm
    {

        public string Term { get; set; }        

        public string Title { get; set; }

        public Type TermType { get; set; }


    }

    public class Query
    {

        public QueryTerm QueryTerm { get; set; }
        public QueryType QueryType { get; set; }
        public string StringValue1 { get; set; }
        public string StringValue2 { get; set; }

        public double DoubleValue1 { get; set; }
        public double DoubleValue2 { get; set; }


        public int IntValue1 { get; set; }
        public int IntValue2 { get; set; }

        public DateTime DateValue1 { get; set; }
        public DateTime DateValue2 { get; set; }

        public string GetValue1()
        {
            if(QueryTerm.TermType==typeof(DateTime))
            {
                return DateValue1.ToString("yyyy-MM-dd");
            }
            else if(QueryTerm.TermType==typeof(double))
            {
                return DoubleValue1.ToString();
            }
            else if (QueryTerm.TermType == typeof(int))
            {
                return IntValue1.ToString();
            }
            else
            {
                return StringValue1;
            }
        }

        public string GetValue2()
        {
            if (QueryTerm.TermType == typeof(DateTime))
            {
                return DateValue2.ToString("yyyy-MM-dd");
            }
            else if (QueryTerm.TermType == typeof(double))
            {
                return DoubleValue2.ToString();
            }
            else if (QueryTerm.TermType == typeof(int))
            {
                return IntValue2.ToString();
            }
            else
            {
                return StringValue2;
            }
        }



    }

    public class QueryType
    {
        public string SQLTemplate { get; set; }

        public int ValueCount { get; set; }

        public string Title { get; set; }
    }
}
